<?php

class Validator_Email extends Zend_Validate_Abstract
{
    const EMAIL = 'emailInvalide';
    
    private $pattern = "#^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$#";
    
    protected $_messageTemplates = array(
    		self::EMAIL => '"%value%" n\'est pas une adresse mail valide');
    
    public function isValid ($value)
    {
    	$this->_setValue($value);
    
    	if(preg_match($this->pattern,$value, $matches))
    	{
    		if($value != $matches[0])
    		{
    			$this->_error(self::EMAIL);
    			return false;
    		}
    		else
    			return true;
    	}
    	else
    	{
    		$this->_error(self::EMAIL);
    		return false;
    	}
    }
}

?>